using System.Collections.Generic;

namespace Coffee.DataModels
{
    /// <summary>
    /// Base DataObject class, with reflection methods built-in for accessing 
    /// properties and methods dynamically on child classes
    /// Please note that for each mapper, (and consequently, each control on a page) 
    /// that is instantiated, TWO instances of the related DataObject will be created:
    /// the T current and T previous members of the DataMapper
    /// </summary>
    public class DataProxy : DataModel
    {
        Dictionary<string, object> properties = new Dictionary<string, object>();

        public void AddProperty(string propertyName)
        {
            properties.Add(propertyName, null);
        }

        public bool PropertyExists(string propertyName)
        {
            return properties.ContainsKey(propertyName);
        }

        public Dictionary<string, object> Properties { get { return properties; } }

        //public override object[] GetPropertyAttributes(string propertyName)
        //{
        //    return null;
        //}


        public override void SetProperty(string propertyName, object value)
        {
            properties[propertyName] = value;
        }

        //public override void InvokeSetter(string methodName, object index, object value)
        //{
        //}

        public override object GetProperty(string propertyName)
        {
            string typeName = "String";
            if (properties[propertyName] != null)
            {
                typeName = properties[propertyName].GetType().Name;
                return properties[propertyName].ToString();
            }
            return string.Empty;
        }

        //public override object GetProperty(string propertyName, object index)
        //{
        //    return null;
        //}

        //public override object InvokeGetter(string methodName, object index)
        //{
        //    return null;
        //}

    }
}